﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

public partial class Manager_IPserver : System.Web.UI.PageEx
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataBinds();
        }
    }
    private int iPageCount = 0;
    private int iRecordCount = 0;
    private string strQuery = string.Empty;
    protected void DataBinds()
    {
        strQuery = "";
        if (!string.IsNullOrEmpty(ttWeb.Text.Trim()))
        {
            strQuery = " and WebUrl like '%" + ttWeb.Text.Trim() + "%'";
        }
        DataSet ds = WebBase.Comm.SelectByPage("ServerWeb", "*", strQuery, "Id", "Id", 0, 1, gridList.PageSize, gridList.PageIndex + 1, out iPageCount, out iRecordCount);
        gridList.RecordCount = iRecordCount;
        gridList.DataSource = ds;
        gridList.DataBind();
    }
    protected void ttboxKeywords_Trigger1Click(object sender, EventArgs e)
    {
        ttWeb.Text = "";
    }
    protected void ttboxKeywords_Trigger2Click(object sender, EventArgs e)
    {
        DataBinds();
    }
    protected void ApplicationEdit_OnClick(object sender, EventArgs e)
    {
        List<int> lstSelectRowId = WebBase.Comm.GetGridSeleteRowId(gridList);
        foreach (int iSelectId in lstSelectRowId)
        {
            Model.ServerWeb model = Dal.ServerWebDal.Select(iSelectId);
            model.StateR = (model.StateR == 1 ? 0 : 1);
            Dal.ServerWebDal.Update(model);
        }
        FineUI.Alert.Show("已修改！！！", FineUI.MessageBoxIcon.Information);
        DataBinds();
    }

    protected void ApplicationDelete_OnClick(object sender, EventArgs e)
    {
        List<int> lstSelectRowId = WebBase.Comm.GetGridSeleteRowId(gridList);
        foreach (int iSelectId in lstSelectRowId)
        {
            Dal.ServerWebDal.Delete(iSelectId);
        }
        FineUI.Alert.Show("已删除！！！", FineUI.MessageBoxIcon.Information);
        DataBinds();
    }

    protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
    {
        int iPageSize = 20;
        int.TryParse(ddlPageSize.SelectedValue, out iPageSize);
        gridList.PageSize = iPageSize;
        DataBinds();
    }
    protected void btnRefresh_Click(object sender, EventArgs e)
    {
        DataBinds();
    }
    protected void gridList_PageIndexChange(object sender, FineUI.GridPageEventArgs e)
    {
        gridList.PageIndex = e.NewPageIndex;
        DataBinds();
    }
    protected void btnAdd_OnClick(object sender, EventArgs e)
    {
        WindowAdd.Hidden = false;
    }
    protected void butsava1_Click(object sender, EventArgs e)
    {
        Model.ServerWeb ServerIPmodel = new Model.ServerWeb();
        ServerIPmodel.WebUrl = txtWeb.Text.Trim();
        ServerIPmodel.spider = txtspider.Text.Trim();
        ServerIPmodel.LastTime = DateTime.Now;
        ServerIPmodel.StateR = Convert.ToInt32(radStateR.SelectedValue);
        Dal.ServerWebDal.Insert(ServerIPmodel);
        DataBinds();
        WindowAdd.Hidden = true;
    }
}
